define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'tide/index' + location.search,
                    add_url: 'tide/add',
                    edit_url: 'tide/edit',
                    del_url: 'tide/del',
                    multi_url: 'tide/multi',
                    import_url: 'tide/import',
                    table: 'tide',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {
                            field: 'day_time',
                            title: __('Day_time'),
                            operate:'RANGE',
                            addclass:'datetimerange',
                            autocomplete:false,
                            formatter: Table.api.formatter.datetime,
                            datetimeFormat:'YYYY-MM-DD'
                        },
                        {field: 'height_0', title: __('Height_0')},
                        {field: 'height_1', title: __('Height_1')},
                        {field: 'height_2', title: __('Height_2')},
                        {field: 'height_3', title: __('Height_3')},
                        {field: 'height_4', title: __('Height_4')},
                        {field: 'height_5', title: __('Height_5')},
                        {field: 'height_6', title: __('Height_6')},
                        {field: 'height_7', title: __('Height_7')},
                        {field: 'height_8', title: __('Height_8')},
                        {field: 'height_9', title: __('Height_9')},
                        {field: 'height_10', title: __('Height_10')},
                        {field: 'height_11', title: __('Height_11')},
                        {field: 'height_12', title: __('Height_12')},
                        {field: 'height_13', title: __('Height_13')},
                        {field: 'height_14', title: __('Height_14')},
                        {field: 'height_15', title: __('Height_15')},
                        {field: 'height_16', title: __('Height_16')},
                        {field: 'height_17', title: __('Height_17')},
                        {field: 'height_18', title: __('Height_18')},
                        {field: 'height_19', title: __('Height_19')},
                        {field: 'height_20', title: __('Height_20')},
                        {field: 'height_21', title: __('Height_21')},
                        {field: 'height_22', title: __('Height_22')},
                        {field: 'height_23', title: __('Height_23')},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});